package com.music.authority.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.music.authority.dao.LoginDao;
import com.music.domain.User;

/**
 * login持久层实现类
 * @author LFSenior
 *
 */
@Repository
public class LoginDaoImpl implements LoginDao {
	@Autowired
	SessionFactory sessionFactory;
	
	@Override
	public User login(String email,String pwd) {
		String hql="from User where email=:email and pwd=:pwd";
		Query query = sessionFactory.getCurrentSession().createQuery(hql);
		query.setParameter("email", email);
		query.setParameter("pwd", pwd);
		List<User> data = query.list();
		if(data==null||data.size()<=0){
			return null;
		}
		return data.get(0);
	}

}
